﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Remote_server
{
    /// <summary>
    /// Delegate used when a command is received
    /// by an RspClient
    /// </summary>
    /// <param name="sender">The RspClient that received
    /// the command</param>
    /// <param name="e">EventArgs containing the command and 
    /// information about the event</param>
    public delegate void CommandReceivedEventHandler(object sender, CommandReceivedEventArgs e);

    /// <summary>
    /// Event arguments passed together with the
    /// CommandReceivedEventHandler delegate when an RspClient
    /// has received a command. These EventArgs expose properties
    /// to control bubbling or tunneling of the event
    /// </summary>
    public class CommandReceivedEventArgs : EventArgs
    {
        /// <summary>
        /// The Command that was received
        /// </summary>
        public Command Command { get; private set; }
        /// <summary>
        /// The time that this instance was created
        /// </summary>
        public DateTime Time { get; private set; }
        /// <summary>
        /// Set to true to indicate that the event is handled
        /// and that bubbling or tunneling should stop
        /// </summary>
        public bool Handled { get; set; }
        /// <summary>
        /// An error description, this may be set to the
        /// cause of the event being stopped
        /// </summary>
        public string Error { get; set; }

        /// <summary>
        /// Constructor initializing the timestamp and
        /// setting the Command property
        /// </summary>
        /// <param name="command">The Command that was received</param>
        public CommandReceivedEventArgs(Command command)
        {
            Command = command;
            Time = DateTime.Now;
            Handled = false;
            Error = "";
        }
    }
}
